<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>优惠券生成</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript">
function search() {
	search_form.action="${webcontext}/crmdp/dealer/coupon/toCouponBatch";
	document.getElementById("search_form").submit();
}

function addCouponBatch(){
	//iframe层
	layer.open({
	    type: 2,
	    title: '添加市场活动',
	    shadeClose: false,
	    closeBtn: false,
	    shade: 0.1, 
	    offset : ['10%' , '25%'],
	    area: ['500px', '250px'],
	    content: '${webcontext}/crmdp/dealer/coupon/toAddCouponBatch' //iframe的url
	}); 
}

function deleteCouponBatch(id){
	jConfirm("确定删除？","确认提示",function(result){
		if(result == true)
		{	
			$("#id").val(id);
			$("form").attr('action','${webcontext}/crmdp/dealer/coupon/deleteCouponBatch');
			$("form").submit();
		}
	});
	
}

function editCouponBatch(id){
	//iframe层
	layer.open({
	    type: 2,
	    title: '编辑市场活动',
	    shadeClose: false,
	    closeBtn: false,
	    scrollbar: false,
	    shade: 0.1, 
	    offset : ['10%' , '25%'],
	    area: ['550px', '500px'],  
	    content: '${webcontext}/crmdp/dealer/coupon/toEditCouponBatch?submitDto.id='+id //iframe的url 
	}); 
}

function exportCoupon(id){
	//iframe层
	layer.open({
	    type: 2,
	    title: '导出优惠券',
	    shadeClose: false,
	    closeBtn: false,
	    scrollbar: false,
	    shade: 0.1, 
	    offset : ['10%' , '25%'],
	    area: ['550px', '500px'],  
	    content: '${webcontext}/crmdp/dealer/coupon/toExportCouponBatch?submitDto.id='+id //iframe的url 
	}); 
}

function generateCoupon(id){
	//iframe层
	layer.open({
	    type: 2,
	    title: '生成优惠券',
	    shadeClose: false,
	    closeBtn: false,
	    shade: 0.1, 
	    offset : ['10%' , '25%'],
	    area: ['550px', '500px'],
	    content: '${webcontext}/crmdp/dealer/coupon/toGenerateCoupon?submitDto.id='+id //iframe的url
	}); 
}

$(function(){
	$("#queryInfo_btn").click(function(){
		search_form.action="${webcontext}/crmdp/dealer/coupon/searchCouponBatch";
		document.getElementById("search_form").submit();
	});
})

</script>

</head>
<body>
	<div id="content">
		<div id="wrap">
			<form:form class="form-horizontal" id="search_form" action="${webcontext}/crmdp/dealer/coupon/toCouponBatch" method="post" >
			<input type="hidden" id="id" name="submitDto.id">
			<div class="row">
				<div class="form-group">
					<label class="col-sm-2 control-label" for="ticketName">名称</label>
					<div class="col-sm-3">
						<input class="form-control input-sm" id="ticketName" name="batchName" type="text" value="${dto.batchName}" />
					</div>
					
					<label class="col-sm-2 control-label" for="startDate">开始日期</label>
					<div class="col-sm-2">
						<input name="transactionStartDate" class="form-control input-sm validate[length[0,100]] date" id="startDate" type="text"
							 value="${dto.transactionStartDate}" />
					</div>
					
					<label class="col-sm-1 control-label text-center" for="endDate">至</label>
					<div class="col-sm-2">
						<input  name="transactionEndDate" class="form-control input-sm validate[length[0,100]] date" id="endDate" type="text" 
						 value="${dto.transactionEndDate}" />
					</div>
				</div>
			</div>
			<div style="text-align: center; margin-top: 10px;">
				<button id="queryInfo_btn" type="button"class="btn btn-success btn-sm" style="width: 100px;">
					<i class="glyphicon glyphicon-search icon" style="color:#FFFFFF"></i>&nbsp;查询
				</button>
				<button type="reset" class="btn btn-success btn-sm" style="width: 100px;">
					<i class="glyphicon glyphicon-trash" style="color:#FFFFFF"></i>&nbsp;重置
				</button>
				<a class="btn btn-success btn-sm" style="width: 150px;" href="javascript:void(0)" onClick="addCouponBatch()">
					<i class="glyphicon glyphicon-plus" style="color:#FFFFFF"></i>&nbsp;添加新市场活动
				</a>
			</div>
				<div class="spliter h_10"></div>
				<table id="table" class="table">
					<tr>
						<th width="25%">市场活动名称</th>
						<th width="25%">活动说明</th>
						<th width="15%">开始日期</th>
						<th width="15%">结束日期</th>
						<th width="20%">操作</th>
					</tr>
					<core:forEach items="${dto.couponBatchList}" var="list"> 
					<tr>
						<td class="align_l">${list.batchName}</td>
						<td class="align_l">${list.description}</td>
						<td class="align_m">${list.startDate}</td>
						<td class="align_m">${list.endDate}</td>
						<td class="align_m">
						<a href="javascript:void(0)" onClick="editCouponBatch('${list.id}')">编辑 </a>
						<core:if test="${list.isBinded == 1}">  	
							<a href="javascript:void(0)" onClick="generateCoupon('${list.id}')">生成</a>
						</core:if>
				<%-- 		<core:if test="${list.isGenerated == 1}"> 
							<a href="javascript:void(0)" onClick="exportCoupon('${list.id}')">导出</a>
						</core:if> --%>
						<core:if test="${list.isGenerated == 0}"> 
							<a href="javascript:void(0)" onClick="deleteCouponBatch('${list.id}')">删除</a>
						</core:if>
						</td> 
					</tr>
					</core:forEach> 
			</table>
		<div class="page_div">
		    <%@include file="../common/page.jsp"%>
		</div>
        </form:form>
        </div>
        </div>
</body>
</html>